package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.CouponReceiveRecordQueryVo;
import cn.ywsj.ywsjmidtier.service.WechatCouponFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "优惠卷")
@RestController
@RequestMapping("/wechat/couponmgr")
public class WechatCouponController {

    @Autowired
    private WechatCouponFeign couponFeign;

    /**
     * 领劵卷中心_领取优惠卷
     * @param couponId
     * @param provideCustId
     * @return
     */
    @ApiOperation("领劵卷中心_领取优惠卷")
    @PostMapping("/receivecoupon")
    public String addProductBookMark(Integer couponId,Integer provideCustId) {
        return couponFeign.addProductBookMark(couponId,provideCustId);
    }

    /**
     * 优惠卷_领卷中心1
     * @param start
     * @param pageSize
     * @return
     */
    @ApiOperation("优惠卷_领卷中心")
    @PostMapping("/getcouponforapp")
    public String getCouponForApp(Integer start,Integer pageSize) {
        return couponFeign.getCouponForApp(start,pageSize);
    }

    /**
     * 优惠卷_我的优惠卷
     * @param queryVo
     * @param start
     * @param pageSize
     * @return
     */
    @ApiOperation("优惠卷_我的优惠卷")
    @PostMapping("/ajaxcouponreceivelistbybuyer")
    public String ajaxCouponReceiveListByBuyer(CouponReceiveRecordQueryVo queryVo,Integer start,Integer pageSize) {
        /*MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
        map.add("isUsed",queryVo.getIsUsed());
        map.add("validity",queryVo.getValidity());*/
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(queryVo);
        return couponFeign.ajaxCouponReceiveListByBuyer(jsonObject,start,pageSize);
    }

}
